/*-------------------------------------------------------------------------

***************** Modification History ***********************************
   @doc
   @module ui.h - Header file for User Interface functionality |
   @end

$Log: /SoftPay/SPK2SIM/Source/Include/ui.h $
**************************************************************************

   Copyright (C) 1999 by VeriFone, Inc.

   All rights reserved.  No part of this software may be reproduced,
   transmitted, transcribed, stored in a retrieval system, or translated
   into any language or computer language, in any form or by any means,
   electronic, mechanical, magnetic, optical, chemical, manual or otherwise,
   without the prior written permission of VeriFone, Inc.

---------------------------------------------------------------------------*/


#ifndef VSUI_H
#define VSUI_H
/******************** Some general key definitions *************************/

#include <applidl.h>                    /* For KEY_CANCEL definition */
#include <svctxo.h>                     /* For GRID_4x12, GRID_4x6, GRID_8x17 */
#include <aclconio.h>					/* for MAX_ALPNUM_KEYS and CHAR_PER_KEY */
#include <actutil.h>

#define BACK_SPACE          0x08        /* Key codes of keys in the Omni */
#define ENTER_KEY           0x0D        /* keyboard, Backspace, enter and */
#define CLEAR_KEY           0x1B        /* Clear key scan values */

#define FUNC_KEY_1          97          /* Function keys in terminal */
#define FUNC_KEY_2          98
#define FUNC_KEY_3          99
#define FUNC_KEY_4          100

#define KEY_YES             1
#define KEY_NO              2

#define KEY_BATCH           1
#define KEY_DATE            2
#define KEY_ALL             3

#define LOOP_DELAY          100         /* Heavily machine dependent */
#define ERR_MSG_DELAY       1000        /* 1 second delay for err msgs */

/****************************************************************************
 *        Parameters to inEnterWithMessage() and inEnterWithString().       *
 ****************************************************************************/

#define INPUT_NUMS              0       /* Input numeric keys only. */
#define INPUT_ALNUMS            1       /* Input alphanumeric keys. */
#define INPUT_NUMS_PWD          2       /* Input numeric keys with asterisk echo. */
#define INPUT_ALNUMS_PWD        3       /* Input alnumeric keys with asterisk echo. */
#define INPUT_FLAG              4       /* Input 1 or 0 */


#define SCROLL_DISPLAY_TRUE     (TRUE)
#define SCROLL_DISPLAY_FALSE    (FALSE)

#define LEFT_JUSTIFY            0
#define CENTER_JUSTIFY          1
#define RIGHT_JUSTIFY           2
#define CLEAR_TITLE             3


#define SIXTEEN_CHAR_PER_ROW     16
#define MAX_CHOICE_PRMPT_SIZE     5
#define DOUBLE_SIXTEEN_CHAR_DISP 32
#define MAX_CHARS_PER_ROW		 21

#ifdef CHAR_PER_KEY
	#undef CHAR_PER_KEY
#endif

#define CHAR_PER_KEY	9

/****************************************************************************
 *                Values for the DisplayInfo data structure.                    *
 ****************************************************************************/

#define CPU_Z80                  0
#define CPU_Z180                 1
#define CPU_68301                2

#define TERMINAL_OMNI_330        0
#define TERMINAL_OMNI_380        1
#define TERMINAL_OMNI_385_LAN    2
#define TERMINAL_OMNI_390        3
#define TERMINAL_OMNI_460        4
#define TERMINAL_OMNI_480        5
#define TERMINAL_OMNI_490        6
#define TERMINAL_OMNI_395        7
#define TERMINAL_OMNI_395_LAN    8
#define TERMINAL_OMNI_385        9
#define TERMINAL_OMNI_392       10
#define TERMINAL_OMNI_396       11
#define TERMINAL_OMNI_470       99
#define TERMINAL_OMNI_3200      14

typedef struct tagDisplayObject
{
    int        	(*inDO_ChooseOne)(char *, char *, char *, int, PFI);
    int        	(*vdDO_idle_logo)(void);
    void       	(*vdDO_UpdateMenu)(void);

	int     	inTitleLine;
	int     	inInputLine;
	int     	inStatusLine;
	int     	inDetailLine;
	int     	inHomeCol;
	int     	inFirstLineCOne;
	int     	inSecondLineCOne;
    int        	in3200BarCol;
    int        	inTopEntryRow;
    int			inTablesInputLine;			// Tables Editing Input Line
    int			inMinPWLength;
    int			inStringMinLength;

    int        	inPrevLangIndex;
    VS_BOOL    	blPrevBigFontOn;  /* T=>PrevFont=Big, F=>PrevFont=Small */
    VS_BOOL    	blCurrBigFontOn;  /* T=>CurrFont=Big, F=>CurrFont=Small */
    int		   	inCurFontType;
    char	   	szFontName[FILENAME_SIZE + 1];

    int         inCharsPerRow;
    int         inCharsPerColumn;
    int         inTerminalType;

    int        	lastX1;           /* For vdSaveDispObjWindow(), vdRestoreDispObjWindow() */
    int        	lastY1;
    int        	lastX2;
    int        	lastY2;

    char       	szDemoMsg   [13+1]; /* Used in idle loop; must preload */
    char       	szLockedMsg [15+1]; /* Used in idle loop; must preload */
    char       	chCaratOffset;

    long		lnChooseOneHotKeys;

    VS_BOOL    	blCfigEdit;
    VS_BOOL    	blEntryNextLine;
    VS_BOOL    	blNextLineCleanup;
    VS_BOOL    	blOptActive;
    VS_BOOL    	blCaratVis;
    VS_BOOL    	blNoScrollEntries;
    VS_BOOL	   	blActionFontASC8x21;
    VS_BOOL	   	blMenuFontASC4x16;

} DisplayObject;

#define NUM_HOTKEYS				4

typedef    struct    tagKeyboardInfo
{
    int     inChoiceKeyCodesOne[4];       /* Values for selection keys for */
                                          /* Omni39X type display (4X25)   */
    int     inChoiceHotKeyCodesOne[NUM_HOTKEYS];    /* Values for HOT keys for */
                                          /* Omni39X type display (4X25)   */
    int     inChoiceKeyCodesTwo[4];       /* Values for selection keys for */
                                          /* type display 1X16. (1&2)*/
    int     inChoiceKeyCodesThreeFour[4]; /* Values for selection keys for */
                                          /* type display 1X16. (1,2,3&4)  */
    long    lChoiceKeyMapsOne[4];         /* Mask for selection keys */
                                          /* for Omni39X type displays (4X25) */
    long    lChoiceHotKeyMapsOne[NUM_HOTKEYS];      /* Mask for HOT keys */
                                          /* for Omni39X type displays (4X25) */
    long    lChoiceKeyMapsTwo[4];         /* Mask for selection keys */
                                          /* for type displays 1X16. (1&2)*/
    long    lChoiceKeyMapsThreeFour[4];   /* Mask for selection keys */
                                          /* for type displays 1X16. (1,2,3&4) */
} KeyboardInfo;


typedef    struct    WindowCoords
{

	int		inLeft;
	int		inRight;
	int		inTop;
	int		inBottom;

} WIN_INFO;

#define		BEEP_DELAY							150
#define   	PROMPT_DELAY                      	1000
#define	  	SHORT_PROMPT_DELAY					(PROMPT_DELAY/2)
#define   	DELAY_SCROLLING_TICKS             	600
#define   	PROMPT_DELAY_SECONDS              	2

#define 	GRID_8X21                  			0
#define 	GRID_4X16                  			1
#define 	GRID_4X8                   			2

/* gu_clr_state changed from kbd_pending_test to act_kbd_pending_test, due to
	issue that top bit gets set due to OS setting high bit to indicate
	keys 'unsecure' Simon_h2 */
#define   gu_clr_state()                    (act_kbd_pending_test(KEY_CANCEL))

extern    DisplayObject  obDisp;

extern void vdUpdateMenu(void);

extern char szKeyMap[MAX_ALPNUM_KEYS][CHAR_PER_KEY];

void vdClearNonTitleLines(void);

void vdClearTitleLine(void);
extern void vdClearLogoLine(void);
extern void vdValidateWindowCoords (int, int *, int *, int *, int *);
extern void vdClearASCII8x21Window(int, int, int, int);
extern void vdUpdateKbdStatusMsg (void);

void vdClearStatusMessage(void);
void vdDisplayResponseString(char *pchDispMsg);
void vdDispStrCentered(char *pchInStr, int inYCord, int inClearDp);
void vdDispStrAtRight(char *pchInStr, int inYCord, int inClearDp);
void vdDisplayString(const char *szMessage);
void vdDisplayErrorString(const char *szErrorString);
void vdDisplayWarningString(const char *szString);
void vdDisplayStatusString(const char *szString);
void vdDispMsgAt(long lnMsgIdx, int inXCord, int inYCord, int inClearDp);
void vdDisplayWarningMsg(long lnMsgIdx);
void vdDispMsgCentered(long lnMsgIdx, int inYCord, int inClearDp);
void vdDispMsgAtRight(long lnMsgIdx, int inYCord, int inClearDp);
void vdDisplayTitle(long lnTitle, int inJustify);
void vdDispFormattedAmt(char *pchAmt, long lnMsgNum, int inLnNum);
void vdDispSettleMsg(char *pchMsg);
void vdDisplayTranTitle(long lnTitle);
void vdDisplayScrollItem ( char * szText, UINT uiStartDelayMs, UINT uiScrollDelayMs, VS_BOOL fAllowKeyAbort, int inStopIndex );
void vdValidateFontFileNames (void);
void vdInitDisplay(void);
void vdDisplayAt(int x, int y, const char *m, int o);
int inMessageLength(long lnMessageNumber);
void vdWarnBeep(void);
void vdBeep(void);
char chGetAlphaKey(char chKey);
void vdFlushKeyboardBuffer(void);
void vdInitCharacterSet(void);
int inWaitForUser(void);
int inWaitKeyWithBeep (int inSeconds, int intDelayBeep);
int inWaitKey(int inSeconds);
void vdPrepareXXXLineChoice(char *pchChoiceMsg, int inNbrChoices, char *pchDispBuf1);
void vdPrepare3200LineChoice(char *pchChoiceMsg, int inNbrChoices, char pchDispBuf1[][MESSAGE_SIZE+1]);
void vdCreateOptWin3200(char szDispBuf[][MESSAGE_SIZE+1]);
void vdDestroyOptWin3200(void);
void vdPrepareOneLineChoice(char *pchChoiceMsg, int inNbrChoices, char *pchBuf1, char *pchBuf2);
void vdTimeAndDisplay(char *pchDispBuf, int inTimeOut);
int inDisplayAndWaitChoice(char *pchDispBuf1, char *pchDispBuf2, char *pchDispBuf3, char *pchDispBuf4,
                    int inBigTimeOut, int inLittleTimeOut);
void vdDispMsgAndStr(char *pchMessageFile, long lnMsgIdx, char *pchBuf, int inLineNo);
int inRotatingDisplayWait(char *pchDispBuf, int inInputLine);
void vdLoad3200Opt(char szLineBuf[][MESSAGE_SIZE+1], long lnMsgId);
int  inGetRowLim(void);
void vdScrollDataEntry (VS_BOOL fScrollDisplay);
void vdSetNextLineEntry(void);
void vdClrNextLineEntry(void);
void vdCleanupNxLine(void);
void vdSetNextLineCleanup(void);
void vdSaveDispObjWindow(void);
void vdRestoreDispObjWindow(void);

int UI_CODE_CHECK(char * a,char *b,short *  c,char * d,unsigned char * e);

#endif /* VSUI_H */



